package cn.edu.jxust.core.infrastructure.mapper;

import cn.edu.jxust.common.domain.entity.Enterprise;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * @author QiuKangming
 * @since 2020-06-29
 */

public interface EnterpriseMapper extends BaseMapper<Enterprise> {

    /**
     * 根据 id 获取企业名称
     * @param areaId 区域id
     * @param id 企业id
     * @return String
     */
    @Select("SELECT enterprise_name FROM t_enterprise WHERE id = #{id} AND area_id = #{areaId} AND status = 1")
    String getEnterNameById(Integer areaId, Integer id);

    /**
     * 判断企业中是否有该区域的企业, 返回个数
     * @param areaId 区域id
     * @return int
     */
    @Select("SELECT COUNT(1) FROM t_enterprise WHERE area_id = #{areaId} AND status = 1")
    int checkEnterpriseArea(Integer areaId);

}
